/**
 * 图层模型父类
 *  子类：S3MLayerModel、GeoJSONLayerModel...
 */
export default class LayerModel {

  static store = window.store;

  constructor(layerInfo){
    this.layerInfo = layerInfo;
    // this.store = store ? store : window.store;
    // this.viewer = viewer;
  }

  // 添加图层
  addLayer(){
    console.log(`${this.constructor.name}类未定义方法：addLayer()`);
  }

  // 删除图层
  removeLayer(){
    console.log(`${this.constructor.name}类未定义方法：removeLayer()`);
  }

  // 飞行
  flyTo(){
    // console.log(`${this.constructor.name}类未定义方法：flyTo()`);

    let cameraParam = this.layerInfo.cameraParam;
    let position = this.layerInfo.position;
    let heading = this.layerInfo.heading;
    let pitch = this.layerInfo.pitch;
    let roll = this.layerInfo.roll;

    // 笛卡三维笛卡尔坐标定位
    if (position) {

      let camera = scene.camera;
      camera.flyTo({
        destination: position,
        orientation: {
          heading: heading,
          pitch: pitch,
          roll: roll
        }
      });
      return true;

    } else if (cameraParam) { // 经纬度坐标定位

      scene.camera.flyTo({
        destination: new Cesium.Cartesian3(cameraParam.Cartesian3.x, cameraParam.Cartesian3.y, cameraParam.Cartesian3.z),
        orientation: {
          heading: cameraParam.heading,
          pitch: cameraParam.pitch,
          roll: cameraParam.roll
        }
      });
      return true;

    }

    return false;
  }

  // 设置图层的可见性
  setVisible(){
    console.log(`${this.constructor.name}类未定义方法：setVisible()`);
  }

}
